Name: Forum Based Auto Close New Threads v1.0

Last modified: 17/05/2006 @ 03:30 (GMT)

Description:
This mod will add a new option to forum options which automatically closes new threads.
This mod can be turned on/off on a per forum basis.

Compatibility: XMB v1.9.5 (Final)

Tested On: XMB 1.9.5 (Final)

Code Developed By: Adam Clarke (http://www.scriptdesign.co.uk & http://www.adam-clarke.co.uk)

MOD History: V1.0 (19/06/2005 @ 19:00) - Initial Release

License Note: This mod is released under the GPL License.

Note: Backup all affected files, templates & database's.

Affected Files: cp.php, post.php, lang/English.lang.php

Affected Templates: NONE




====================================================================================================
STEP 1: Goto Administration Panel -->  Insert Raw SQL.

Upload SQL.txt and click Submit Changes.
====================================================================================================




====================================================================================================
STEP 2: Edit File 'cp.php'

Find Code:
----------------------------------------------------------------------------------------------------

        $type31 = $type32 = $type33 = $type34 = '';
        if ($forum['private'] == "2") {
            $type32 = "selected";
        } elseif ($forum['private'] == "3") {
            $type33 = "selected";
        } elseif ($forum['private'] == "4") {
            $type34 = "selected";
        } elseif ($forum['private'] == "1") {
            $type31 = "selected";
        }

----------------------------------------------------------------------------------------------------

Add Code Below:
----------------------------------------------------------------------------------------------------

        // Forum Based Auto Close New Threads Mod Begin
        $closethreads_on = $closethreads_off = '';
        switch ($forum['closethreads']) {
            case 'on':
                $closethreads_on = $selHTML;
            default:
                $closethreads_off = $selHTML;
        }
        // Forum Based Auto Close New Threads Mod End

----------------------------------------------------------------------------------------------------


Find Code:
----------------------------------------------------------------------------------------------------

        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['texttheme']?></td>
        <td bgcolor="<?php echo $altbg2?>"><?php echo $themelist?></td>
        </tr>

----------------------------------------------------------------------------------------------------

Add Code Below:
----------------------------------------------------------------------------------------------------

        <?php
        printsetting1($lang['closethreadsstatus'], 'closethreadsnew', $closethreads_on, $closethreads_off);
        ?>

----------------------------------------------------------------------------------------------------


Find Code:
----------------------------------------------------------------------------------------------------

            if ($newfname != $lang['textnewforum']) {
                $newfname = addslashes($newfname);
                $db->query("INSERT INTO $table_forums ( type, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting ) VALUES ('forum', '$newfname', '$newfstatus', '', '', ".(int)$newforder.", '1', '', 'no', 'yes', 'yes', '', 0, 0, 0, ".(int)$newffup.", '1|1', 'yes', 'on', 'on', '', 'off')");
            }

----------------------------------------------------------------------------------------------------

Find Code In Above Code:
----------------------------------------------------------------------------------------------------

) VALUES ('forum',

----------------------------------------------------------------------------------------------------

Replace Code With:
----------------------------------------------------------------------------------------------------

, closethreads) VALUES ('forum',

----------------------------------------------------------------------------------------------------

Add Code To End Of Same Line, Before: )");
----------------------------------------------------------------------------------------------------

, 'off'

----------------------------------------------------------------------------------------------------


Find Code:
----------------------------------------------------------------------------------------------------

            if ($newgname != $lang['textnewgroup']) {
                $newgname = addslashes($newgname);
                $db->query("INSERT INTO $table_forums ( type, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting ) VALUES ('group', '$newgname', '$newgstatus', '', '', ".(int)$newgorder.", '', '', '', '', '', '', 0, 0, 0, 0, '', '', '', '', '', 'off')");
            }

----------------------------------------------------------------------------------------------------

Find Code In Above Code:
----------------------------------------------------------------------------------------------------

) VALUES ('forum',

----------------------------------------------------------------------------------------------------

Replace Code With:
----------------------------------------------------------------------------------------------------

, closethreads) VALUES ('forum',

----------------------------------------------------------------------------------------------------

Add Code To End Of Same Line, Before: )");
----------------------------------------------------------------------------------------------------

, 'off'

----------------------------------------------------------------------------------------------------


Find Code:
----------------------------------------------------------------------------------------------------

            if ($newsubname != $lang['textnewsubf']) {
                $newsubname = addslashes($newsubname);
                $db->query("INSERT INTO $table_forums ( type, name, status, lastpost, moderator, displayorder, private, description, allowhtml, allowsmilies, allowbbcode, userlist, theme, posts, threads, fup, postperm, allowimgcode, attachstatus, pollstatus, password, guestposting ) VALUES ('sub', '$newsubname', '$newsubstatus', '', '', ".(int)$newsuborder.", '1', '', 'no', 'yes', 'yes', '', 0, 0, 0, ".(int)$newsubfup.", '1|1', 'yes', 'on', 'on', '', 'off')");
            }

----------------------------------------------------------------------------------------------------

Find Code In Above Code:
----------------------------------------------------------------------------------------------------

) VALUES ('forum',

----------------------------------------------------------------------------------------------------

Replace Code With:
----------------------------------------------------------------------------------------------------

, closethreads) VALUES ('forum',

----------------------------------------------------------------------------------------------------

Add Code To End Of Same Line, Before: )");
----------------------------------------------------------------------------------------------------

, 'off'

----------------------------------------------------------------------------------------------------


Find Code:
----------------------------------------------------------------------------------------------------

$db->query("UPDATE $table_forums SET name='$namenew',

----------------------------------------------------------------------------------------------------

Add Code To End Of Same Line, Before: WHERE fid='$fdetails'");
----------------------------------------------------------------------------------------------------

, closethreads='$closethreadsnew'

----------------------------------------------------------------------------------------------------
====================================================================================================




====================================================================================================
STEP 3: Edit File 'post.php'

Find Code:
----------------------------------------------------------------------------------------------------

        if ((X_STAFF) && $toptopic == "yes") {
            $db->query("UPDATE $table_threads SET topped='1' WHERE tid='$tid' AND fid='$fid'");
        }
        if ((X_STAFF) && $closetopic == "yes") {
            $db->query("UPDATE $table_threads SET closed='yes' WHERE tid='$tid' AND fid='$fid'");
        }

----------------------------------------------------------------------------------------------------

Replace Code With:
----------------------------------------------------------------------------------------------------

        if ((X_STAFF) && $toptopic == "yes") {
            $db->query("UPDATE $table_threads SET topped='1' WHERE tid='$tid' AND fid='$fid'");
        }
        if (((X_STAFF) && $closetopic == "yes") || $forum['closethreads'] == 'on') {
            $db->query("UPDATE $table_threads SET closed='yes' WHERE tid='$tid' AND fid='$fid'");
        }

----------------------------------------------------------------------------------------------------
====================================================================================================




====================================================================================================
STEP 8: Edit File 'lang/English.lang.php'

Add Code To End Of File:
----------------------------------------------------------------------------------------------------

// Forum Based Auto Close New Threads Mod Begin
$lang['closethreadsstatus'] = 'Auto Close New Threads Status:';
// Forum Based Auto Close New Threads Mod End

----------------------------------------------------------------------------------------------------
====================================================================================================
